<template>
  <a-card :bordered="false">
    <!-- 默认全换成 include需要缓存的页面名字aliCouponList -->
    <keep-alive include="aliCouponList">
      <component
        @onEdit="handleEdit"
        @onGoBack="handleGoBack"
        :record="record"
        :is="currentComponet"></component>
    </keep-alive>
  </a-card>
</template>

<script>
import aliCouponList from './aliCouponList'
import aliCouponEdit from './aliCouponEdit'

export default {
  name: 'Info',
  components: {
    aliCouponList,
    aliCouponEdit
  },
  data () {
    return {
      currentComponet: 'aliCouponList',
      record: ''
    }
  },
  methods: {
    handleEdit (record) {
      if (record == 'null') { // 新建
        this.record = ''
      } else {
        this.record = record
      }
      this.currentComponet = 'aliCouponEdit'
    },
    handleGoBack () {
      this.record = ''
      this.currentComponet = 'aliCouponList'
    }
  },
  watch: {
    '$route.path' () {
      this.record = ''
      this.currentComponet = 'aliCouponList'
    }
  }
}
</script>
